package org.douxiaoban.client.activity;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.Toast;
import org.douxiaoban.client.R;
import org.douxiaoban.client.app.App;
import org.douxiaoban.client.app.Assistant;

import java.util.prefs.Preferences;


/**
 * Created by IntelliJ IDEA.
 * User: huangzhongkun
 * Date: 11-3-23
 * Time: 上午1:07
 */
public class MainActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        SharedPreferences sharedPreferences = PreferenceManager.
                getDefaultSharedPreferences(this);

        String token_key = sharedPreferences.getString(Assistant.SETTING_ACCESS_TOKEN_KEY,"");
        String token_secret = sharedPreferences.getString(Assistant.SETTING_ACCESS_TOKEN_SECRET,"");
        
        if(token_key==null||token_secret==null
                ||token_key.equals("")||token_secret.equals("") || App.userId ==null
                || App.username == null || App.username.equals("")||App.userId.equals("")){
            Intent welcomeIntent = new Intent (MainActivity.this,WelcomeActivity.class);
            welcomeIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(welcomeIntent);
            finish();
        }else {
            App.getDouanApiInstance().setAccessToken();
            Intent navigIntent = new Intent(MainActivity.this,NavigationActivity.class);
            navigIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(navigIntent);
            finish();
        }
     }
}
